{
	class Graph {
		edges = 0 // 边
		adj: (string | number)[][] = []
		constructor(public vertices = 0) {
			for (let i = 0; i < this.vertices; i++) {
				this.adj[i] = []
				this.adj[i].push('') // 自己不可能和自己相连
			}
		}

		addEdge(v: number, w: number) {
			this.adj[v].push(w)
			this.adj[w].push(v)
			this.edges++
		}

		showGraph() {
			for (let i = 0; i < this.vertices; i++) {
				console.log(i + '->')
				for (let j = 0; j < this.vertices; j++) {
					if (this.adj[j][j] !== undefined) {
						console.log(this.adj[i][j])
					}
				}
				console.log('--------')
			}
		}
	}

	let g = new Graph(5)
	g.addEdge(0, 1)
	g.addEdge(0, 2)
	g.addEdge(1, 3)
	g.addEdge(2, 4)
	g.showGraph()
	// console.log(g.adj)
}
